/**
 * 质数之和
 * @param num
 * @returns {boolean}
 */
function isPrimeNum(num) {
    if(typeof num !== "number"){
        return false;
    }else if(num<2){
        return false
    }else if(num == 2){
        return true;
    }else if(num % 2 === 0){
        return false;
    }

    let sq = Math.sqrt(num);
    for (let i=3;i<=sq;i+=2){
        if (num % i === 0){
            return false;
        }
    }
    return true;
}

function sumPrimes(num) {
    let sum = 0;
    if(num>=2){
        for(let i=2;i<=num;i++){
            if (isPrimeNum(i))
            sum += i;
        }
    }else {
        return '参数过小';
    }
    return sum;
}

console.log(sumPrimes(977));
sumPrimes(10);